using ASP;
using HoWave.Common;
using HoWave.Web;
using HoWave.Web.Shop.Member;
using System;
using System.Collections;
using System.Data;
using System.Web.Profile;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
public class Shop_member_ShopComplain : Member, IRequiresSessionState
{
	protected ScriptManager ScriptManager1;
	protected LinkButton LinkButton1;
	protected LinkButton LinkButton2;
	protected LinkButton LinkButton3;
	protected DropDownList DropType;
	protected DropDownList DropStatus;
	protected TextBox startTime;
	protected TextBox EndTime;
	protected Button SeachBut;
	protected GridView GridView1;
	protected PlaceHolder PlaceHolder1;
	protected DropDownList DropType1;
	protected DropDownList DropStatus1;
	protected TextBox StartTime1;
	protected TextBox EndTime1;
	protected Button btn_search2;
	protected GridView GridView2;
	protected PlaceHolder PlaceHolder2;
	protected Literal ltrTitle;
	protected RadioButtonList RadioType;
	protected TextBox TxtComplainUserName;
	protected RequiredFieldValidator Rq2;
	protected TextBox TxtReason;
	protected RequiredFieldValidator Rq1;
	protected TextBox txtResult;
	protected RequiredFieldValidator rfvResult;
	protected HtmlTableRow tr_result;
	protected Button ButAdd;
	protected PlaceHolder PlaceHolder3;
	private int ComplainUserID = 0;
	private int UserID = 0;
	private string UserName;
	public string m_flag = "0";
	private string whereStr1 = "";
	private string whereStr2 = "";
	private ArrayList al = new ArrayList();
	private Shop_Complain _shop_complain = null;
	private int _reviewComplainID = 0;
	private string _Complain_SelType = "";
	protected DefaultProfile Profile
	{
		get
		{
			return (DefaultProfile)this.Context.Profile;
		}
	}
	protected global_asax ApplicationInstance
	{
		get
		{
			return (global_asax)this.Context.ApplicationInstance;
		}
	}
	protected Shop_Complain shop_complain
	{
		get
		{
			Shop_Complain shop_complain;
			if (this._shop_complain == null)
			{
				this._shop_complain = new Shop_Complain(this.conn);
				shop_complain = this._shop_complain;
			}
			else
			{
				shop_complain = this._shop_complain;
			}
			return shop_complain;
		}
	}
	public int ReviewComplainID
	{
		get
		{
			if (base.Request.QueryString["ReviewComplainID"] != null)
			{
				string text = base.Request.QueryString["ReviewComplainID"].ToString();
				if (!string.IsNullOrEmpty(text))
				{
					this._reviewComplainID = text.ToInt32(new int[0]);
				}
			}
			return this._reviewComplainID;
		}
	}
	public string Complain_SelType
	{
		get
		{
			if (base.Request.QueryString["Complain_SelType"] != null)
			{
				this._Complain_SelType = base.Request.QueryString["Complain_SelType"].ToString();
			}
			return this._Complain_SelType;
		}
	}
	protected void Page_Load(object sender, EventArgs e)
	{
		this.UserID = int.Parse(Fetch.GetCookies("Howave_UserID"));
		this.UserName = base.user.UserName;
		this.startTime.Attributes.Add("onClick", string.Concat(new string[]
		{
			"show_cele_date(",
			this.startTime.UniqueID,
			",'','',",
			this.startTime.UniqueID,
			");"
		}));
		this.EndTime.Attributes.Add("onClick", string.Concat(new string[]
		{
			"show_cele_date(",
			this.EndTime.UniqueID,
			",'','',",
			this.EndTime.UniqueID,
			");"
		}));
		this.StartTime1.Attributes.Add("onClick", string.Concat(new string[]
		{
			"show_cele_date(",
			this.StartTime1.UniqueID,
			",'','',",
			this.StartTime1.UniqueID,
			");"
		}));
		this.EndTime1.Attributes.Add("onClick", string.Concat(new string[]
		{
			"show_cele_date(",
			this.EndTime1.UniqueID,
			",'','',",
			this.EndTime1.UniqueID,
			");"
		}));
		if (!base.IsPostBack)
		{
			this.bindMyComplain();
			this.bindReiveComplain();
			this.BindTypeStatus();
			if (base.Request.QueryString["OtherReviewComplainID"] != null)
			{
				int userID = int.Parse(base.Request.QueryString["OtherReviewComplainID"].ToString());
				UserBll userBll = new UserBll();
				this.TxtComplainUserName.Text = userBll.GetUserByUserID(userID).Rows[0]["UserName"].ToString();
				this.ButAdd.Enabled = true;
				this.PlaceHolder3.Visible = true;
				this.PlaceHolder1.Visible = (this.PlaceHolder2.Visible = false);
			}
			if (this.ReviewComplainID > 0)
			{
				this.InitComplainInfo();
			}
			if (base.Request.QueryString["ComplainUserID"] != null)
			{
				this.ComplainUserID = int.Parse(base.Request.QueryString["ComplainUserID"].ToString());
				UserBll userBll2 = new UserBll();
				if (userBll2.GetUserByUserID(this.ComplainUserID).Rows.Count >= 1)
				{
					this.TxtComplainUserName.Text = userBll2.GetUserByUserID(this.ComplainUserID).Rows[0]["username"].ToString();
				}
				this.PlaceHolder3.Visible = true;
			}
			if (!string.IsNullOrEmpty(this.Complain_SelType))
			{
				this.ShowPanelDisplay(this.Complain_SelType);
			}
		}
	}
	private void InitComplainInfo()
	{
		if (this.ReviewComplainID > 0)
		{
			this.m_flag = "2";
			DataTable complainByComplainID = this.shop_complain.GetComplainByComplainID(this.ReviewComplainID);
			string text = "";
			if (complainByComplainID.Columns.Contains("ComplainType"))
			{
				if (complainByComplainID.Rows[0]["ComplainType"] != DBNull.Value)
				{
					text = complainByComplainID.Rows[0]["ComplainType"].ToString();
				}
			}
			if (!string.IsNullOrEmpty(text))
			{
				for (int i = 0; i < this.RadioType.Items.Count; i++)
				{
					this.RadioType.Items[i].Selected = false;
				}
				this.RadioType.rblSelect(text);
			}
			this.TxtComplainUserName.Text = complainByComplainID.Rows[0]["ComplainUserName"].ToString();
			this.TxtReason.Text = complainByComplainID.Rows[0]["Reason"].ToString();
			this.txtResult.Text = complainByComplainID.Rows[0]["Result"].ToString();
			this.RadioType.Enabled = true;
			this.TxtComplainUserName.Enabled = true;
			this.TxtReason.Enabled = true;
			this.tr_result.Visible = true;
			this.ButAdd.Enabled = false;
			if (base.ActionTabInfo == "editinfo")
			{
				this.RadioType.Enabled = false;
				this.TxtComplainUserName.Enabled = false;
				this.TxtReason.Enabled = false;
				this.ButAdd.Enabled = true;
				this.ButAdd.Text = "处理结果";
			}
			this.PlaceHolder3.Visible = true;
			this.PlaceHolder1.Visible = (this.PlaceHolder2.Visible = false);
		}
	}
	public void BindTypeStatus()
	{
		this.DropType.Items.Add("投诉/举报");
		this.DropType.Items.Add("投诉");
		this.DropType.Items.Add("举报");
		this.DropType.Items[0].Selected = true;
		this.DropStatus.Items.Add("状态");
		this.DropStatus.Items.Add("待处理");
		this.DropStatus.Items.Add("处理完毕");
		this.DropStatus.Items[0].Selected = true;
	}
	private void bindMyComplain()
	{
		DataTable myComplainByUserID = this.shop_complain.getMyComplainByUserID(base.user.UserID);
		this.GridView1.DataSource = myComplainByUserID;
		this.GridView1.DataBind();
	}
	private void bindReiveComplain()
	{
		DataTable revieComplainByUserID = this.shop_complain.getRevieComplainByUserID(base.user.UserID);
		this.GridView2.DataSource = revieComplainByUserID;
		this.GridView2.DataBind();
		for (int i = 0; i < this.GridView2.Rows.Count; i++)
		{
			GridViewRow gridViewRow = this.GridView2.Rows[i];
			HiddenField hiddenField = (HiddenField)gridViewRow.FindControl("hfStatus");
			HyperLink hyperLink = (HyperLink)gridViewRow.FindControl("hlEditResult");
			if (hiddenField != null)
			{
				string a = hiddenField.Value.ToLower().Trim();
				if (a == "1" || a == "true")
				{
					if (hyperLink != null)
					{
						hyperLink.Visible = false;
					}
				}
				else
				{
					if (hyperLink != null)
					{
						hyperLink.Visible = true;
					}
				}
			}
		}
	}
	protected void IComplain_SelectType(object sender, CommandEventArgs e)
	{
		this.ShowPanelDisplay(e.CommandName);
	}
	protected void ShowPanelDisplay(string DisplayName)
	{
		if (DisplayName != null)
		{
			if (!(DisplayName == "myComplain"))
			{
				if (!(DisplayName == "receiveComplain"))
				{
					if (DisplayName == "complainOther")
					{
						this.m_flag = "2";
						this.PlaceHolder1.Visible = false;
						this.PlaceHolder2.Visible = false;
						this.PlaceHolder3.Visible = true;
						this.TxtComplainUserName.Text = (this.TxtReason.Text = "");
						this.RadioType.Enabled = true;
						this.TxtComplainUserName.Enabled = true;
						this.TxtReason.Enabled = true;
						this.ButAdd.Enabled = true;
						this.tr_result.Visible = false;
						this.ButAdd.Text = "添加";
					}
				}
				else
				{
					this.m_flag = "1";
					this.PlaceHolder1.Visible = false;
					this.PlaceHolder2.Visible = true;
					this.PlaceHolder3.Visible = false;
				}
			}
			else
			{
				this.m_flag = "0";
				this.PlaceHolder1.Visible = true;
				this.PlaceHolder2.Visible = false;
				this.PlaceHolder3.Visible = false;
			}
		}
	}
	protected void ButAdd_Click(object sender, EventArgs e)
	{
		if (this.Page.IsValid)
		{
			if (base.ActionTabInfo == "editinfo")
			{
				string result = this.txtResult.Text.Trim();
				bool flag = false;
				if (this.ReviewComplainID > 0)
				{
					flag = this.shop_complain.EditComplainResultByComplainID(this.ReviewComplainID, 1, result);
				}
				if (flag)
				{
					this.WriteSuccessMsg("", "信息处理成功！", "Shop_Complain.aspx?Complain_SelType=receiveComplain");
				}
				else
				{
					this.WriteSuccessMsg("", "信息处理失败！", "Shop_Complain.aspx?Complain_SelType=receiveComplain");
				}
			}
			else
			{
				string text = this.TxtComplainUserName.Text;
				if (base.user.UserName == text)
				{
					this.WriteErrMsg("", Language.Get("PassPort/NotComplain"), "");
				}
				else
				{
					UserBll userBll = new UserBll();
					DataTable userByUserName = userBll.GetUserByUserName(text);
					if (userByUserName.Rows.Count > 0)
					{
						this.ComplainUserID = int.Parse(userByUserName.Rows[0]["userid"].ToString());
						this.ButAdd.Enabled = true;
						this.ButAdd.Text = "添加";
						bool flag2 = this.shop_complain.AddComplain(this.UserID, this.RadioType.SelectedValue, this.ComplainUserID, text, this.TxtReason.Text, 0, "", DateTime.Now, this.UserName);
						if (flag2)
						{
							this.Page.Response.Redirect("Shop_Complain.aspx");
						}
						else
						{
							this.WriteErrMsg("", Language.Get("PassPort/NoUserName"), "");
						}
					}
					else
					{
						this.WriteErrMsg("", Language.Get("PassPort/NoUserName"), "");
					}
				}
			}
		}
	}
	protected void GridView1_OnDataBound(object sender, EventArgs e)
	{
		foreach (GridViewRow gridViewRow in this.GridView1.Rows)
		{
			Label label = (Label)gridViewRow.FindControl("resultBar");
			Label label2 = (Label)gridViewRow.FindControl("TxtResult");
			if (label != null)
			{
				label.Attributes.Add("onmouseover", "document.getElementById('" + label2.ClientID + "').style.display='';");
				label.Attributes.Add("onmouseout", "document.getElementById('" + label2.ClientID + "').style.display='none';");
			}
			if (label2 != null)
			{
				label2.Attributes.Add("class", "showDiv");
				label2.Attributes.Add("style", "display: none;");
			}
			Label label3 = (Label)gridViewRow.FindControl("reasonBar");
			Label label4 = (Label)gridViewRow.FindControl("TxtReason");
			if (label3 != null)
			{
				label3.Attributes.Add("onmouseover", "document.getElementById('" + label4.ClientID + "').style.display='';");
				label3.Attributes.Add("onmouseout", "document.getElementById('" + label4.ClientID + "').style.display='none';");
			}
			if (label4 != null)
			{
				label4.Attributes.Add("class", "showDiv");
				label4.Attributes.Add("style", "display: none;");
			}
		}
	}
	protected void GridView2_OnDataBound(object sender, EventArgs e)
	{
		foreach (GridViewRow gridViewRow in this.GridView2.Rows)
		{
			Label label = (Label)gridViewRow.FindControl("resultBar");
			Label label2 = (Label)gridViewRow.FindControl("TxtResult");
			if (label != null)
			{
				label.Attributes.Add("onmouseover", "document.getElementById('" + label2.ClientID + "').style.display='';");
				label.Attributes.Add("onmouseout", "document.getElementById('" + label2.ClientID + "').style.display='none';");
			}
			if (label2 != null)
			{
				label2.Attributes.Add("class", "showDiv");
				label2.Attributes.Add("style", "display: none;");
			}
			Label label3 = (Label)gridViewRow.FindControl("reasonBar");
			Label label4 = (Label)gridViewRow.FindControl("TxtReason");
			if (label3 != null)
			{
				label3.Attributes.Add("onmouseover", "document.getElementById('" + label4.ClientID + "').style.display='';");
				label3.Attributes.Add("onmouseout", "document.getElementById('" + label4.ClientID + "').style.display='none';");
			}
			if (label4 != null)
			{
				label4.Attributes.Add("class", "showDiv");
				label4.Attributes.Add("style", "display: none;");
			}
		}
	}
	protected void QueryString()
	{
		string text = this.startTime.Text;
		if (text != string.Empty)
		{
			if (!Text.IsDate(text))
			{
				this.WriteErrMsg("", Language.Get("Common/DateTimeFormatErr"), "");
			}
			this.whereStr1 += "and DateDiff(dd,startTime, @BeginDate)<=0 ";
			this.al.Add(this.conn.CreateParameter("@BeginDate", DbType.DateTime, text));
		}
		string text2 = this.EndTime.Text;
		if (text2 != string.Empty)
		{
			if (!Text.IsDate(text2))
			{
				this.WriteErrMsg("", Language.Get("Common/DateTimeFormatErr"), "");
			}
			if (text != string.Empty)
			{
				if (Convert.ToDateTime(text) > Convert.ToDateTime(text2))
				{
					this.WriteErrMsg("", Language.Get("Common/DateTimeErr"), "");
				}
			}
			this.whereStr1 += "and DateDiff(dd,startTime, @EndDate)>=0 ";
			this.al.Add(this.conn.CreateParameter("@EndDate", DbType.DateTime, text2));
		}
		string text3;
		if (this.DropType.SelectedIndex == 0)
		{
			text3 = "";
		}
		else
		{
			text3 = this.DropType.SelectedValue;
		}
		if (text3 != string.Empty)
		{
			this.whereStr1 = this.whereStr1 + " and ComplainType='" + text3 + "'";
		}
		int num = 1;
		if (this.DropStatus.SelectedIndex == 0)
		{
			num = 2;
		}
		if (this.DropStatus.SelectedIndex == 1)
		{
			num = 0;
		}
		if (this.DropStatus.SelectedIndex == 2)
		{
			num = 1;
		}
		if (num != 2)
		{
			this.whereStr1 = this.whereStr1 + " and Status=" + num;
		}
		if (this.whereStr1 != string.Empty)
		{
			this.whereStr1 = "and" + this.whereStr1;
			this.whereStr1 = this.whereStr1.Replace("andand", "");
		}
	}
	protected void QueryString1()
	{
		string text = this.StartTime1.Text;
		if (text != string.Empty)
		{
			if (!Text.IsDate(text))
			{
				this.WriteErrMsg("", Language.Get("Common/DateTimeFormatErr"), "");
			}
			this.whereStr2 += "and DateDiff(dd,startTime, @BeginDate)<=0 ";
			this.al.Add(this.conn.CreateParameter("@BeginDate", DbType.DateTime, text));
		}
		string text2 = this.EndTime1.Text;
		if (text2 != string.Empty)
		{
			if (!Text.IsDate(text2))
			{
				this.WriteErrMsg("", Language.Get("Common/DateTimeFormatErr"), "");
			}
			if (text != string.Empty)
			{
				if (Convert.ToDateTime(text) > Convert.ToDateTime(text2))
				{
					this.WriteErrMsg("", Language.Get("Common/DateTimeErr"), "");
				}
			}
			this.whereStr2 += "and DateDiff(dd,startTime, @EndDate)>=0 ";
			this.al.Add(this.conn.CreateParameter("@EndDate", DbType.DateTime, text2));
		}
		string text3;
		if (this.DropType1.SelectedIndex == 0)
		{
			text3 = "";
		}
		else
		{
			text3 = this.DropType1.SelectedValue;
		}
		if (text3 != string.Empty)
		{
			this.whereStr2 = this.whereStr2 + " and ComplainType='" + text3 + "'";
		}
		int num = 2;
		if (this.DropStatus1.SelectedIndex == 0)
		{
			num = 2;
		}
		if (this.DropStatus1.SelectedIndex == 1)
		{
			num = 0;
		}
		if (this.DropStatus1.SelectedIndex == 2)
		{
			num = 1;
		}
		if (num != 2)
		{
			this.whereStr2 = this.whereStr2 + " and Status=" + num;
		}
		if (this.whereStr2 != string.Empty)
		{
			this.whereStr2 = "and" + this.whereStr2;
			this.whereStr2 = this.whereStr2.Replace("andand", "");
		}
	}
	protected void SeachBut_Click(object sender, EventArgs e)
	{
		string str = "";
		string str2 = "";
		string str3 = "";
		switch (this.DropType.SelectedIndex)
		{
		case 0:
			str = "";
			break;
		case 1:
			str = "投诉";
			break;
		case 2:
			str = "举报";
			break;
		}
		if (this.DropType.SelectedIndex > 0)
		{
			str2 = " and ComplainType='" + str + "'";
		}
		string str4;
		if (this.DropStatus.SelectedIndex == 0)
		{
			str4 = " and (Status='false' or Status='true') ";
		}
		else
		{
			if (this.DropStatus.SelectedIndex == 1)
			{
				str4 = " and Status='false' ";
			}
			else
			{
				str4 = " and Status='true' ";
			}
		}
		if (this.startTime.Text != "" && this.EndTime.Text != "")
		{
			str3 = string.Concat(new string[]
			{
				" and StartTime>='",
				this.startTime.Text,
				"' and StartTime<='",
				this.EndTime.Text,
				"'"
			});
		}
		string text = str2 + str4 + str3;
		this.GridView1.DataSource = this.conn.GetDataSet(string.Concat(new object[]
		{
			"select * from HLShop_Complain where UserID=",
			this.UserID,
			" ",
			text
		}));
		this.GridView1.DataBind();
	}
	protected void btn_search2_Click(object sender, EventArgs e)
	{
		string str = "";
		string str2 = "";
		string str3 = "";
		switch (this.DropType1.SelectedIndex)
		{
		case 0:
			str = "";
			break;
		case 1:
			str = "投诉";
			break;
		case 2:
			str = "举报";
			break;
		}
		if (this.DropType1.SelectedIndex > 0)
		{
			str2 = " and ComplainType='" + str + "'";
		}
		string str4;
		if (this.DropStatus1.SelectedIndex == 0)
		{
			str4 = " and (Status='false' or Status='true') ";
		}
		else
		{
			if (this.DropStatus1.SelectedIndex == 1)
			{
				str4 = " and Status='false'";
			}
			else
			{
				str4 = " and Status='true'";
			}
		}
		if (this.StartTime1.Text != "" && this.EndTime1.Text != "")
		{
			str3 = string.Concat(new string[]
			{
				" and StartTime>='",
				this.StartTime1.Text,
				"' and StartTime<='",
				this.EndTime1.Text,
				"'"
			});
		}
		string text = str2 + str4 + str3;
		this.GridView2.DataSource = this.conn.GetDataSet(string.Concat(new object[]
		{
			"select * from HLShop_Complain where ComplainUserID=",
			this.UserID,
			" ",
			text
		}));
		this.GridView2.DataBind();
		this.ShowPanelDisplay("receiveComplain");
	}
}
